<?php


namespace App\Modules\Seller\Http\Controllers;


use App\Modules\Seller\Http\Requests\Rabc\SellerAdminRequest;
use App\Modules\Seller\Services\Seller\SellerAdminServices;
use App\Modules\Admin\Services\Seller\SellerAuthServices;
use Illuminate\Http\Request;

class AuthController  extends BaseController
{
    protected $guard = 'seller_admin';

    public function __construct(SellerAuthServices $authService)
    {
        $this->service = $authService;
    }

    /**
     * 登录流程
     *
     * @param LoginRequest $request
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\Admin\AuthException
     * @throws \App\Exceptions\InvalidRequestException
     */
    public function login(SellerAdminRequest $request)
    {
        $data = $request->validated();
        // 登录流程
        $token = $this->service->login($request,$data);

        return $this->successJson($token);
    }

    /**
     * 获取登录管理员信息
     *
     * @return \Illuminate\Http\JsonResponse
     * @throws \App\Exceptions\Admin\AuthException
     */
    public function me()
    {
        if (\request()->getMethod() == 'OPTIONS'){
            return $this->successJson();
        }

        return $this->successJson($this->service->me());
    }
    public function getRabcList(){

        return $this->successJson($this->service->getRabcList());
    }

}